7d6818613e859da6d3134c0e5a5608f197b92014,clc/modules/www/src/main/java/edu/ucsb/eucalyptus/admin/client/EucalyptusWebInterface.java,EucalyptusWebInterface,displayUserRecordPage,#Panel#UserInfoWeb#,465
Before Change
g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
affiliation_box.setText (userToEdit.getAffiliation());
affiliation_box.setWidth("360");
affiliation_box.addKeyboardListener(sl);
g2.setWidget( i++, 1, affiliation_box );
}
After Change
g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
telephoneNumber_box.setWidth("180");
telephoneNumber_box.setText (userToEdit.getTelephoneNumber());
telephoneNumber_box.setTabIndex(i);
g2.setWidget( i++, 1, telephoneNumber_box );
}
if (request_project_leader) {
g2.setWidget( i, 0, new Label( "Project Leader:" ) );
g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
projectPIName_box.setText (userToEdit.getProjectPIName());
projectPIName_box.setWidth("180");
projectPIName_box.setTabIndex(i);
g2.setWidget( i++, 1, projectPIName_box );
}
if (request_affiliation) {
g2.setWidget( i, 0, new Label( "Affiliation:" ) );
g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
affiliation_box.setText (userToEdit.getAffiliation());
affiliation_box.setWidth("360");
affiliation_box.setTabIndex(i);
g2.setWidget( i++, 1, affiliation_box );
}
if (request_project_description) {
g2.setWidget( i, 0, new Label( "Project Description:" ) );
g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
projectDescription_box.setText (userToEdit.getProjectDescription());
projectDescription_box.setWidth("360");
projectDescription_box.setHeight("50");
projectDescription_box.setTabIndex(i);
g2.setWidget( i++, 1, projectDescription_box );
}
}
ClickListener SignupButtonListener = new ClickListener() {
public void onClick( Widget sender )
{
boolean formOk = true;
for ( int j = 0; j < 4; j++ )
{
g1.clearCell( j, 2 ); /* clear previous right-hand-side annotations */
}
// perform checks
if ( userName_box.getText().length() < 1 )
{
Label l = new Label( "Username is empty!" );
l.setStyleName("euca-error-hint");
g1.setWidget( userName_row, 2, l);
formOk = false;
} else {
// do this in the else-clause so the empty username doesn't match here
if ( cleartextPassword1_box.getText().toLowerCase().matches(".*" +
userName_box.getText().toLowerCase() + ".*")) {
Label l = new Label ( "Password may not contain the username!");
l.setStyleName("euca-error-hint");
g1.setWidget( password1_row, 2, l );
formOk = false;
}
}
if ( userName_box.getText().matches(".*[^\\w\\-\\.@]+.*") ) {
Label l = new Label ("Invalid characters in the username!");
l.setStyleName ("euca-error-hint");
g1.setWidget (userName_row, 2, l);
formOk = false;
}
if ( userName_box.getText().length() > 30)
{
Label l = new Label( "Username is too long, sorry!" );
l.setStyleName("euca-error-hint");
g1.setWidget( userName_row, 2, l);
formOk = false;
}
if ( cleartextPassword1_box.getText().length() < minPasswordLength )
{
Label l = new Label( "Password must be at least " + minPasswordLength + " characters long!" );
l.setStyleName("euca-error-hint");
g1.setWidget( password1_row, 2, l );
formOk = false;
}
if ( !cleartextPassword1_box.getText().equals( cleartextPassword2_box.getText() ) )
{
Label l = new Label( "Passwords do not match!" );
l.setStyleName("euca-error-hint");
g1.setWidget( password2_row, 2, l );
formOk = false;
}
if ( realName_box.getText().equalsIgnoreCase(cleartextPassword1_box.getText())
|| userName_box.getText().equalsIgnoreCase(cleartextPassword1_box.getText())) {
Label l = new Label ( "Password may not be your name or username!");
l.setStyleName("euca-error-hint");
g1.setWidget( password1_row, 2, l );
formOk = false;
}
if ( realName_box.getText().length() < 1 )
{
Label l = new Label( "Name is empty!" );
l.setStyleName("euca-error-hint");
g1.setWidget( realName_row, 2, l );
formOk = false;
}
if ( emailAddress_box.getText().length() < 1 )
{
Label l = new Label( "Email address is empty!" );
l.setStyleName("euca-error-hint");
g1.setWidget( emailAddress_row, 2, l );
formOk = false;
} else if ( !emailAddress_box.getText().contains("@") ) {
Label l = new Label( "Email address does not look like an email address!" );
l.setStyleName("euca-error-hint");
g1.setWidget( emailAddress_row, 2, l );
formOk = false;
}
if ( formOk )
{
label_box.setText( "Checking with the server..." );
label_box.setStyleName("euca-greeting-pending");
String enteredPassword = cleartextPassword1_box.getText();
String encryptedPassword = GWTUtils.md5(enteredPassword);
if ( enteredPassword.equals(oldPassword)) {
encryptedPassword = enteredPassword; // it was not changed in the edit
}
final UserInfoWeb userToSave = new UserInfoWeb(
userName_box.getText(),
realName_box.getText(),
emailAddress_box.getText(),
encryptedPassword);
if ( admin ) {
userToSave.setAdministrator( userIsAdmin.isChecked());
if ( showSkipConfirmed ) {
previousSkipConfirmation = skipConfirmation.isChecked(); // remember value for the future
userToSave.setConfirmed(previousSkipConfirmation);
}
}
if ( telephoneNumber_box.getText().length() > 0 )
{
userToSave.setTelephoneNumber( telephoneNumber_box.getText() );
}
if ( affiliation_box.getText().length() > 0 )
{
userToSave.setAffiliation( affiliation_box.getText() );
}
if ( projectDescription_box.getText().length() > 0 )
{
userToSave.setProjectDescription( projectDescription_box.getText() );
}
if ( projectPIName_box.getText().length() > 0 )
{
userToSave.setProjectPIName( projectPIName_box.getText() );
}
if (newUser) {
EucalyptusWebBackend.App.getInstance().addUserRecord(
sessionId, /* will be null if anonymous user signs up */
userToSave,
new AsyncCallback() {
public void onSuccess( Object result )
{
displayDialog( "Thank you!", ( String ) result );
}
public void onFailure( Throwable caught )
{
String m = caught.getMessage();
if ( m.equals( "User already exists" ) )
{
g1.setWidget( userName_row, 2, new Label( "Username is taken!" ) );
label_box.setText( "Please, fix the error and resubmit:" );
label_box.setStyleName("euca-greeting-warning");
} else {
displayErrorPage(m);
}
}
}
);
} else {
EucalyptusWebBackend.App.getInstance().updateUserRecord(
sessionId,
userToSave,
new AsyncCallback() {
public void onSuccess(Object result) {
if (loggedInUser.getUserName().equals(userToSave.getUserName())) {
loggedInUser.setRealName(userToSave.getRealName());
loggedInUser.setEmail(userToSave.getEmail());
loggedInUser.setPassword(userToSave.getPassword());
loggedInUser.setTelephoneNumber(userToSave.getTelephoneNumber());
loggedInUser.setAffiliation(userToSave.getAffiliation());
loggedInUser.setProjectDescription(userToSave.getProjectDescription());
loggedInUser.setProjectPIName(userToSave.getProjectPIName());
displayDialog("", (String) result);
} else { // admin updating a user
displayBarAndTabs("");
statusMessage.setText( ( String ) result );
}
}
public void onFailure( Throwable caught )
{
String m = caught.getMessage();
displayErrorPage(m);
}
}
);
}
}
else
{
label_box.setText( "Please, fix the errors and resubmit:" );
label_box.setStyleName("euca-greeting-warning");
}
}
};
Button submit_button;
if (newUser) {
if (admin) {
submit_button = new Button ( "Add user", SignupButtonListener);
} else {
submit_button = new Button ( "Sign up", SignupButtonListener);
}
} else {
submit_button = new Button ( "Update Record", SignupButtonListener );
}
submit_button.setTabIndex (i++);
Button cancel_button = new Button( "Cancel", DefaultPageButtonListener );
cancel_button.setTabIndex (i++);
VerticalPanel mpanel = new VerticalPanel();
mpanel.add( label_mandatory );
mpanel.add( g1 );
VerticalPanel opanel = new VerticalPanel();
if (extra_fields > 0) {
opanel.add( label_optional );
opanel.add( g2 );
}
HorizontalPanel bpanel = new HorizontalPanel();
bpanel.add( submit_button );
bpanel.add( new HTML( " or " ) );
bpanel.add( cancel_button );
VerticalPanel vpanel = new VerticalPanel();
vpanel.setSpacing(15);
vpanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
vpanel.add(new HTML("<br/>"));
if (logo!=null) { addLogoWithText(vpanel); vpanel.add(new HTML("<br/>"));};
vpanel.add (label_box);
vpanel.add (mpanel);
vpanel.add (opanel);
vpanel.add (bpanel);
VerticalPanel wrapper = new VerticalPanel();
wrapper.add (vpanel);
wrapper.setSize("100%", "100%");
wrapper.setCellHorizontalAlignment(vpanel, VerticalPanel.ALIGN_CENTER);
// wrapper.setCellVerticalAlignment(vpanel, VerticalPanel.ALIGN_MIDDLE);
parent.clear();
parent.add( wrapper );
EucalyptusKeyboardListener sl = new EucalyptusKeyboardListener(submit_button, cancel_button);
userName_box.addKeyboardListener(sl);
cleartextPassword1_box.addKeyboardListener(sl);
cleartextPassword2_box.addKeyboardListener(sl);
realName_box.addKeyboardListener(sl);
emailAddress_box.addKeyboardListener(sl);
telephoneNumber_box.addKeyboardListener(sl);
projectPIName_box.addKeyboardListener(sl);
affiliation_box.addKeyboardListener(sl);
projectDescription_box.addKeyboardListener(sl);
submit_button.addKeyboardListener(sl);
cancel_button.addKeyboardListener(sl);